package com.cheer.ba.view.adapter;

import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.cheer.ba.R;
import com.cheer.ba.constant.IntentCode;
import com.cheer.ba.model.OilGoodsInfoModel;
import com.cheer.ba.utils.Currency;
import com.cheer.ba.utils.ImageUtils;
import com.cheer.ba.utils.Protect;
import com.cheer.ba.utils.StringUtils;

import java.util.List;

/**
 * 柴油批发界面
 */
public class FindOilAdp extends BaseQuickAdapter<OilGoodsInfoModel, BaseViewHolder> {

    private int page;

    public FindOilAdp(@LayoutRes int layoutResId, @Nullable List<OilGoodsInfoModel> data) {
        super(layoutResId, data);
    }

    public FindOilAdp(@LayoutRes int layoutResId, @Nullable List<OilGoodsInfoModel> data, int page) {
        super(layoutResId, data);
        this.page = page;
    }

    @Override
    protected void convert(BaseViewHolder helper, OilGoodsInfoModel item) {
        if (page == IntentCode.General.JUMP_OILMENU) {
            //公司下的
            helper.getView(R.id.id_oil_company_txt).setVisibility(View.GONE);
        } else {
            helper.addOnClickListener(R.id.id_oil_company_txt);
            helper.setText(R.id.id_oil_company_txt, item.orgNickName);
        }
        //进入商品详情
        helper.addOnClickListener(R.id.id_jump_detail_linear);

        helper.setText(R.id.id_oil_time_txt, StringUtils.getDetailStr1(item.createTime));
        ImageUtils.showRoundImg(mContext, Protect.setPic(item.orgLogo), R.drawable.ic_bg_oil_sale, R.drawable.ic_bg_oil_sale, (ImageView) helper.getView(R.id.id_oil_pic));
        helper.setText(R.id.id_oil_title_txt, "柴油 0# " + (TextUtils.equals("1", item.oilModel) ? "国IV " : "国V "));
        helper.setText(R.id.id_oil_price_txt, Currency.returnDollar(item.tonPrice) + "/吨");
        helper.setText(R.id.id_oil_density_txt, "密度：" + item.oilDensity);
        helper.setText(R.id.id_oil_type_txt, item.sourceName);
        helper.setText(R.id.id_oil_num_txt, "库存：" + StringUtils.returnKG(item.stock));
        if ("1".equals(item.isRecommend)) {
            helper.getView(R.id.id_oil_recommend_img).setVisibility(View.VISIBLE);
        } else {
            helper.getView(R.id.id_oil_recommend_img).setVisibility(View.GONE);
        }
        helper.getView(R.id.id_oil_send_pay_linear).setVisibility(View.GONE);
        helper.getView(R.id.id_order_btn_linear).setVisibility(View.GONE);
    }
}
